package handler

import (
	"errors"
	"strings"

	"gorm.io/gorm"
)

func checkPassword(password string) error {
	if len(password) < 6 {
		return errors.New("password min length: 6")
	}

	return nil
}

func checkNickname(nick string) error {
	nick = strings.Trim(nick, " ")

	if len(nick) == 0 {
		return errors.New("nickname can`t be empty")
	}

	return nil
}

func isNicknameUnique(nick *gorm.DB) error {
	if nick.RowsAffected > 0 {
		return errors.New("this nickname already exists")
	}

	return nil
}
